<?php
class GroupController extends AppController {
	var $autoRender = true;
	var $uses = array (
			'Groups',
			'Topics' 
	);
	var $layout = 'default';
	function index() {
		echo 'asdf';
		exit ();
	}
	function create_group() {
	}
	function do_create_group() {
		$_SESSION["nick_name"] = 'shihaixiao';
		foreach ( $_POST as $key => $value ) {
			$_POST [$key] = filter_content ( $value );
		}
		$create_time = date ( 'Y-m-d H:i:s' );
		$data = array (
				'id' => null,
				'name' => $_POST ['name'],
				'brief' => $_POST ['brief'],
				'reason' => $_POST ['reason'],
				'tag' => $_POST ['tag'],
				'managers' => $_SESSION["nick_name"],
				'apply_type' => $_POST ['apply_type'],
				'status' => 0,
				'create_time' => $create_time,
				'update_time' => $create_time 
		);
		print_r($data);
		$ret = $this->Groups->save ( $data );
		var_dump($ret);
		exit();
	}
	function do_create_topic() {
		foreach ( $_POST as $key => $value ) {
			$_POST [$key] = filter_content ( $value );
		}
		$create_time = date ( 'Y-m-d H:i:s' );
		$common_id = get_common_id();
		$data = array (
				'id' => null,
				'topic_id' => $common_id,
				'title' => $_POST ['title'],
				'content' => $_POST ['content'],
				'user_id' => $_SESSION["user_id"],
				'tag' => $_POST ['tag'],
				'group_id' => $_POST ['group_id'],
				'create_time' => $create_time,
				'update_time' => $create_time 
		);
		$ret = $this->Topics->save ( $data );
		return $ret;
	}
}